package com.xd.pre.modules.tpshop.controller;

import com.xd.pre.common.utils.Result;
import com.xd.pre.modules.tpshop.service.ITpShippingAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lx
 * @since 2020-06-03
 */
@RestController
@RequestMapping("/ShippingArea")
public class TpShippingAreaController {
    @Autowired
    private ITpShippingAreaService sa_biz;

    // 先根据 镇 县 区找 shipping_area_id
    //【1】 http://localhost:8080/tpshop_server/ShippingArea/find_shipping_area_id?shipping_code=sto_express&region_id=5			// 测试已通过！！
    @RequestMapping(value = "/find_shipping_area_id", method = RequestMethod.GET)
    public Result find_shipping_area_id(HttpServletRequest request) {
        Result result = new Result();

        String shipping_code = request.getParameter("shipping_code"); //
        String region_id = request.getParameter("region_id"); //
        if (null != shipping_code && !"".equals(shipping_code) && null != region_id && !"".equals(region_id)) {
            result.setData(sa_biz.find_shipping_area_id(shipping_code, Integer.valueOf(region_id))); // -1代表 在db中没有找到结果！
        }

        return result;
    }


}
